package com.hgw.Demo07_ObserverPattern.JDKObserverPattern;

import java.util.Observable;

/**
 * Data time:2021/12/19 16:43
 * StudentID:2019112118
 * Author:hgw
 * Description: 小偷是一个被观察者，继承Observable类，具体目标
 */
public class Thief extends Observable {
    private String name;

    public Thief(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void steal() {
        System.out.println("小偷：我偷东西了，有没有人来抓我！！！");
        super.setChanged();     // changed = true
        super.notifyObservers();
    }
}
